package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.GpsObjectRelationDao;
import cn.topevery.garden.entity.po.GpsObjectRelation;
import cn.topevery.garden.entity.query.GpsObjectRelationQuery;
import cn.topevery.garden.entity.vo.GpsObjectRelationVO;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import org.springframework.stereotype.Repository;


/**
 * 
 *
 * @author code-generate
 * @date 2021-08-30
 */
@Repository
public class GpsObjectRelationDaoImpl extends BaseDaoImpl<GpsObjectRelation> implements GpsObjectRelationDao {

    @Override
    public DataPager<GpsObjectRelationVO> listPage(GpsObjectRelationQuery query) {
        String table = "t_gps_object_relation tgor";

        String columns = "tgor.*";
        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tgor.c_id desc");
        sqlQueryMate
                .where(true, "tgor.c_db_status", ScriptConditionEnum.Eq, 0)
                .where(query.getGpsId() != null, "tgor.c_gps_id", ScriptConditionEnum.Eq, query.getGpsId());

        return getDataPager(sqlQueryMate, pageSize, pageIndex, GpsObjectRelationVO.class);
    }
}
